<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Number')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-number" data-rule="required" class="form-control" name="row[number]" type="text">-->
<!--        </div>-->
<!--    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">单据类型:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="number_type" id="number_type" class="form-control">
                <option value="1">入库单</option>
                <option value="2">出库单</option>
                <option value="3">厂家直发</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">经手人:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="admin_id" id="admin_id" class="form-control">
                {volist name="admins" id="vo"}
                     <option value="{$vo.id}">{$vo.nickname}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">单据编号:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-sale_number" data-rule="required" class="form-control" name="source_number" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">费用类型:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="type" id="" class="form-control">
                {volist name="types" id="vo"}
                <option value="{$key}">{$vo}</option>
                {/volist}
            </select>
<!--            <input id="c-type" data-rule="required" class="form-control" name="row[type]" type="number">-->
        </div>
    </div>
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Sales_checkout_id')}:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="c-sales_checkout_id" data-rule="required" data-source="sales/checkout/index" class="form-control selectpage" name="row[sales_checkout_id]" type="text" value="">-->
<!--        </div>-->
<!--    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">金额:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-cost" data-rule="required" class="form-control" step="0.01" name="cost" type="text" onkeyup="checkTaxFloat(this);">
        </div>
    </div>
<!--    <div class="form-group">-->
<!--        <label class="control-label col-xs-12 col-sm-2">是否支出:</label>-->
<!--        <div class="col-xs-12 col-sm-8">-->
<!--            <input id="" data-rule="required"   name="is_income" type="radio" value="1">收入-->
<!--            <input id="" data-rule="required"   name="is_income" type="radio" value="2">支出-->
<!--        </div>-->
<!--    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea rows="3" cols="20" class="form-control" name="remark"></textarea>
<!--            <input id="c-remark" data-rule="required" class="form-control" name="row[remark]" type="text" value="">-->
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>
    function checkTaxFloat(obj) {
        // obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
        var x = obj.value.indexOf('.') + 2;   //小数点的位置
        var y = obj.value.length;
        if(x>1 && (y-x) >0){
            if((y-x)>1){
                obj.value= parseFloat(obj.value).toFixed(1)
            }
        }
        // if(obj.value.indexOf(".")< 0 && obj.value !=""){
        //     obj.value= parseFloat(obj.value)
        // }
    }
</script>
